package com.yunduan.management.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yunduan.management.entity.Members;
import com.yunduan.management.service.MembersService;
import com.yunduan.management.utils.JsonObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description:
 * @author: hy
 * @date: 2020/11/5 21:30
 * @QQ群: 975366488
 */
@RestController
@CrossOrigin
public class MemberController {
    @Autowired
    private MembersService membersService;

    @GetMapping("/getMembersByLevel")
    public JsonObject getMembersByLevel(String level){
        QueryWrapper<Members> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("level",level);
        return new JsonObject().success(membersService.list(queryWrapper));
    }

    @GetMapping("/getAllMembers")
    public JsonObject getAllMembers(){
        return new JsonObject().success(membersService.list());
    }

    @GetMapping("/getMemberById")
    public JsonObject getMemberById(Long id){
        Members members = membersService.getById(id);
        return new JsonObject().success(members);
    }
}
